\(\int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx\) [672]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [F(-2)]
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 39, antiderivative size = 46 \[ \int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx=\frac {a (A+B \tan (e+f x))^2}{2 (i A+B) c^2 f (1-i \tan (e+f x))^2} \]

[Out]

1/2*a*(A+B*tan(f*x+e))^2/(I*A+B)/c^2/f/(1-I*tan(f*x+e))^2

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.051, Rules used = {3669, 37} \[ \int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx=\frac {a (A+B \tan (e+f x))^2}{2 c^2 f (B+i A) (1-i \tan (e+f x))^2} \]

[In]

Int[((a + I*a*Tan[e + f*x])*(A + B*Tan[e + f*x]))/(c - I*c*Tan[e + f*x])^2,x]

[Out]

(a*(A + B*Tan[e + f*x])^2)/(2*(I*A + B)*c^2*f*(1 - I*Tan[e + f*x])^2)

Rule 37

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_), x_Symbol] :> Simp[(a + b*x)^(m + 1)*((c + d*x)^(n +
1)/((b*c - a*d)*(m + 1))), x] /; FreeQ[{a, b, c, d, m, n}, x] && NeQ[b*c - a*d, 0] && EqQ[m + n + 2, 0] && NeQ
[m, -1]

Rule 3669

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a*(c/f), Subst[Int[(a + b*x)^(m - 1)*(c + d*x)^(n - 1)*(A + B*x), x
], x, Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, A, B, m, n}, x] && EqQ[b*c + a*d, 0] && EqQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(a c) \text {Subst}\left (\int \frac {A+B x}{(c-i c x)^3} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {a (A+B \tan (e+f x))^2}{2 (i A+B) c^2 f (1-i \tan (e+f x))^2} \\ \end{align*}

Mathematica [A] (verified)

Time = 2.56 (sec) , antiderivative size = 44, normalized size of antiderivative = 0.96 \[ \int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx=-\frac {a (A+B \tan (e+f x))^2}{2 (i A+B) c^2 f (i+\tan (e+f x))^2} \]

[In]

Integrate[((a + I*a*Tan[e + f*x])*(A + B*Tan[e + f*x]))/(c - I*c*Tan[e + f*x])^2,x]

[Out]

-1/2*(a*(A + B*Tan[e + f*x])^2)/((I*A + B)*c^2*f*(I + Tan[e + f*x])^2)

Maple [A] (verified)

Time = 0.14 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.00

method result size
derivativedivides \(\frac {a \left (-\frac {-i A -B}{2 \left (i+\tan \left (f x +e \right )\right )^{2}}+\frac {i B}{i+\tan \left (f x +e \right )}\right )}{f \,c^{2}}\) \(46\)
default \(\frac {a \left (-\frac {-i A -B}{2 \left (i+\tan \left (f x +e \right )\right )^{2}}+\frac {i B}{i+\tan \left (f x +e \right )}\right )}{f \,c^{2}}\) \(46\)
risch \(-\frac {a \,{\mathrm e}^{4 i \left (f x +e \right )} B}{8 c^{2} f}-\frac {i a \,{\mathrm e}^{4 i \left (f x +e \right )} A}{8 c^{2} f}+\frac {a \,{\mathrm e}^{2 i \left (f x +e \right )} B}{4 c^{2} f}-\frac {i a \,{\mathrm e}^{2 i \left (f x +e \right )} A}{4 c^{2} f}\) \(80\)
norman \(\frac {\frac {A a \tan \left (f x +e \right )}{c f}+\frac {i a B \tan \left (f x +e \right )^{3}}{c f}+\frac {-i A a +B a}{2 c f}+\frac {\left (i A a +3 B a \right ) \tan \left (f x +e \right )^{2}}{2 c f}}{c \left (1+\tan \left (f x +e \right )^{2}\right )^{2}}\) \(95\)

[In]

int((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x,method=_RETURNVERBOSE)

[Out]

1/f*a/c^2*(-1/2*(-I*A-B)/(I+tan(f*x+e))^2+I*B/(I+tan(f*x+e)))

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.00 \[ \int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx=\frac {{\left (-i \, A - B\right )} a e^{\left (4 i \, f x + 4 i \, e\right )} - 2 \, {\left (i \, A - B\right )} a e^{\left (2 i \, f x + 2 i \, e\right )}}{8 \, c^{2} f} \]

[In]

integrate((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="fricas")

[Out]

1/8*((-I*A - B)*a*e^(4*I*f*x + 4*I*e) - 2*(I*A - B)*a*e^(2*I*f*x + 2*I*e))/(c^2*f)

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 153 vs. \(2 (36) = 72\).

Time = 0.20 (sec) , antiderivative size = 153, normalized size of antiderivative = 3.33 \[ \int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx=\begin {cases} \frac {\left (- 8 i A a c^{2} f e^{2 i e} + 8 B a c^{2} f e^{2 i e}\right ) e^{2 i f x} + \left (- 4 i A a c^{2} f e^{4 i e} - 4 B a c^{2} f e^{4 i e}\right ) e^{4 i f x}}{32 c^{4} f^{2}} & \text {for}\: c^{4} f^{2} \neq 0 \\\frac {x \left (A a e^{4 i e} + A a e^{2 i e} - i B a e^{4 i e} + i B a e^{2 i e}\right )}{2 c^{2}} & \text {otherwise} \end {cases} \]

[In]

integrate((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))**2,x)

[Out]

Piecewise((((-8*I*A*a*c**2*f*exp(2*I*e) + 8*B*a*c**2*f*exp(2*I*e))*exp(2*I*f*x) + (-4*I*A*a*c**2*f*exp(4*I*e)
- 4*B*a*c**2*f*exp(4*I*e))*exp(4*I*f*x))/(32*c**4*f**2), Ne(c**4*f**2, 0)), (x*(A*a*exp(4*I*e) + A*a*exp(2*I*e
) - I*B*a*exp(4*I*e) + I*B*a*exp(2*I*e))/(2*c**2), True))

Maxima [F(-2)]

Exception generated. \[ \int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [A] (verification not implemented)

none

Time = 0.45 (sec) , antiderivative size = 79, normalized size of antiderivative = 1.72 \[ \int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx=-\frac {2 \, {\left (A a \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} + i \, A a \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - B a \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - A a \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )\right )}}{c^{2} f {\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}^{4}} \]

[In]

integrate((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="giac")

[Out]

-2*(A*a*tan(1/2*f*x + 1/2*e)^3 + I*A*a*tan(1/2*f*x + 1/2*e)^2 - B*a*tan(1/2*f*x + 1/2*e)^2 - A*a*tan(1/2*f*x +
 1/2*e))/(c^2*f*(tan(1/2*f*x + 1/2*e) + I)^4)

Mupad [B] (verification not implemented)

Time = 9.03 (sec) , antiderivative size = 51, normalized size of antiderivative = 1.11 \[ \int \frac {(a+i a \tan (e+f x)) (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx=\frac {\frac {a\,\left (-B+A\,1{}\mathrm {i}\right )}{2}+B\,a\,\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}}{c^2\,f\,\left ({\mathrm {tan}\left (e+f\,x\right )}^2+\mathrm {tan}\left (e+f\,x\right )\,2{}\mathrm {i}-1\right )} \]

[In]

int(((A + B*tan(e + f*x))*(a + a*tan(e + f*x)*1i))/(c - c*tan(e + f*x)*1i)^2,x)

[Out]

((a*(A*1i - B))/2 + B*a*tan(e + f*x)*1i)/(c^2*f*(tan(e + f*x)*2i + tan(e + f*x)^2 - 1))